package org.cocos2dx.javascript.Mob;

import android.content.Context;
import android.content.SharedPreferences;

public class SdkSetting {
    private static SharedPreferences share;
    private static String configPath = "sdkSetting";

    public static SharedPreferences getSetting(Context context){
        try{
            share = context.getSharedPreferences(configPath, Context.MODE_PRIVATE);
        }
        catch(Exception e){
            e.printStackTrace();
        }

        return share;
    }

    public static void saveSeting(Context context, String key, String value){
        try{
            share = context.getSharedPreferences(configPath, Context.MODE_PRIVATE);
            SharedPreferences.Editor editor = share.edit();

            editor.putString(key, value);

            editor.commit();
        }
        catch(Exception e){
            e.printStackTrace();
        }
    }

    public static String getSetting(Context context, String key){
        try {
            share = context.getSharedPreferences(configPath, Context.MODE_PRIVATE);
            return share.getString(key, "");
        }
        catch (Exception e){
            e.printStackTrace();
        }

        return "";
    }
}
